Setting Up the Target Environment

Now it’s time to install the machines and networks that will make up our

simulated corporate target. You can perform this installation in two ways:

manually or using an automated script.

We encourage you to set up your lab manually at least once by following the

instructions in this section. This will allow you to familiarize yourself with the

lab’s core components and practice running commands on the command line.

However, if you ever need to redeploy the lab from scratch in a fresh installation

of Kali, you can do so by executing the init.sh script at

https://github.com/dolevf/Black-Hat-Bash/blob/master/lab/init.sh:

$ cd ~/Black-Hat-Bash/lab

$ chmod u+x init.sh

$ ./init.sh

This script should install all of the lab’s dependencies, containers, and hacking

utilities, enabling you to skip the instructions in this section and in “Installing

Additional Hacking Tools” on page XX. You must execute the script in a Kali

virtual machine that meets the system requirements described in the introduction to

this chapter.

Installing Docker and Docker Compose

We’ll build the lab environment using Docker, a tool for deploying and

managing containers. Containers package code and its dependencies so an

application can run reliably in various environments. We’ll also make use of

Docker Compose, a special Docker utility used to orchestrate the building and

management of multiple Docker containers using a single YAML file, known as a

Compose file.

Lets first configure our sources to use Debians current stable version of

Dockers community edition, docker-ce, using the following commands. We use

printf to add Dockers Advanced Package Tool (APT) repository to the APT

package-source database file. The tee command reads from standard input stream

and writes to a file:

$ printf '%s\n' "deb https://download.docker.com/linux/debian bullseye stable" |

sudo tee /etc/apt/sources.list.d/docker-ce.list

Next, download and import Docker’s keyring to ensure that the repository is

validated and all packages installed from that repository are cryptographically

verified. We use curl to download the key and pipe it to the gpg command,

which will then store it in the required folder:

$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o

/etc/apt/trusted.gpg.d/docker-ce-archive-keyring.gpg

Finally, run another update to refresh the repository database and install the

Docker components:

$ sudo apt update -y

Black Hat Bash (Early Access) © 2023 by Dolev Farhi and Nick Aleks